---
name: main-cacher
on:
  push:
    branches:
    - 'main'
permissions:
  contents: read
jobs:
  get-dev-image:
    uses: ./.github/workflows/get_image.yaml
    with:
      image-base-name: "dev_image"
  populate-caches:
    runs-on: ubuntu-latest-8-cores
    needs: get-dev-image
    container:
      image: ${{ needs.get-dev-image.outputs.image-with-tag }}
      options: --cpus 7
    steps:
    - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3  # v3.5.0
    - name: go cache
      uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8  # v3.3.1
      with:
        path: /px/pkg/mod
        key: go-cache-${{ hashFiles('go.sum') }}
        restore-keys: |
          go-cache-
    - name: yarn cache
      uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8  # v3.3.1
      with:
        path: ./src/ui/.yarn/cache
        key: yarn-cache-${{ hashFiles('src/ui/yarn.lock', 'src/ui/.yarnrc.yml') }}
        restore-keys: |
          yarn-cache-
    - shell: bash
      run: |
        go mod download;
        pushd src/ui > /dev/null;
        yarn install;
        popd > /dev/null;
